package jk.spider.api.event.engine;

import java.util.Date;

import jk.spider.core.Spider;
import jk.spider.core.SpiderController;


public abstract class SpideringStoppedEvent {
	protected static Spider spider;
	protected static SpiderController controller;
	
	public SpideringStoppedEvent() {}
	
	public synchronized static void setSpider(final Spider spider) {
		SpideringStoppedEvent.spider = spider;
	}
	
	public synchronized static void setSpiderController(final SpiderController controller) {
		SpideringStoppedEvent.controller = controller;
	}
	
	public synchronized void shutDown() {
		controller.getStorage().getResourceDAO().setEndTime();
		Date[] crawlDate = controller.getStorage().getResourceDAO().getCrawlDate();
	    System.out.println((crawlDate[1].getTime() - crawlDate[0].getTime()) * 1000);
		this.preStop();
	}
	
	public abstract void preStop();
	
}
